<template>
  <el-tag
    v-for="tag in tags"
    :key="tag.name"
    class="mx-1"
    @close="del(tag.name)"
    :type="tag.type"
    effect="light"
    closable
    @click="toRoute(tag.name)"
  >
    {{ tag.name }}
  </el-tag>
</template>

<script setup>
import { ref, } from 'vue'
import {useRoute,useRouter} from 'vue-router';
//引入pinia
import {useCounterStore} from '../store/tag';
import {storeToRefs} from 'pinia' 
const use = useCounterStore();
const route = useRoute();
const router = useRouter();
console.log(use);
let {tags} = storeToRefs(useCounterStore());
//跳转
const toRoute = (name)=>{
  router.push({name})
}
//关闭
const del = (name)=>{
  //console.log(name);
  use.remoteTags(name);
  //tags = use.tags;
}
</script>